home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / fg / fgmisc10 / scrolltx.c < prev    next >
Text File  |  1993-10-25  |  4KB  |  117 lines

  1. /****************************************************************************\
  2. *                                                                            *
  3. *  SCROLLTX.C                                                                *
  4. *                                                                            *
  5. *  Copyright 1993 Diana Gruber. All rights reserved.                         *
  6. *                                                                            *
  7. *  Scroll bitmapped text horizontally in an EGA mode. The trick to this      *
  8. *  program is fg_transfer transfers on byte boundaries. Because a byte       *
  9. *  boundary in mode 13 occurs every 8 pixels, to scroll horizontally in      *
  10. *  one-pixel increments, you must have 8 copies of the text on the hidden    *
  11. *  page.                                                                     *
  12. *                                                                            *
  13. *  This program scrolls one line of text, but the idea can be extended to    *
  14. *  multiple lines of text. The font is the simple fixed-pitch bitmapped      *
  15. *  font defined in CHAR.C. If you want better fonts, you can create your     *
  16. *  own or use Fastgraph/Fonts.                                               *
  17. *                                                                            *
  18. *  See MISC.DOC for compile and link commands.                               *
  19. *                                                                            *
  20. \****************************************************************************/
  21.  
  22. #include "defs.h"
  23. #include "scrolltx.h"
  24.  
  25. void main()
  26. {
  27.  
  28.    /* initialize the video mode to 320x200x16 EGA graphics */
  29.  
  30.    init_graphics(13);
  31.  
  32.    /* draw some rectangles */
  33.  
  34.    fg_setcolor(1);
  35.    fg_rect(0,319,0,239);
  36.    fg_setcolor(15);
  37.    fg_rect(24,295,15,24);
  38.    fg_setcolor(0);
  39.    fg_box(23,296,14,25);
  40.    fg_waitfor(9);
  41.  
  42.    /* scroll the message across */
  43.  
  44.    scroll_status_message("The rain in Spain.");
  45.    fg_waitkey();
  46.  
  47.    /* exit to DOS */
  48.  
  49.    quit_graphics();
  50. }
  51.  
  52. /****************************************************************************\
  53. *                                                                            *
  54. *  scroll_status_message -- one pixel horizontal text scrolling              *
  55. *                                                                            *
  56. \****************************************************************************/
  57.  
  58. void scroll_status_message(char *message)
  59. {
  60.    int minx, maxx, miny;
  61.    int newx, newy;
  62.    register int x, y;
  63.    int delay;
  64.  
  65.    /* clear the workspace on the hidden page */
  66.  
  67.    fg_setpage(HIDDEN);
  68.    fg_setcolor(15);
  69.    fg_rect(0,319,0,80);
  70.  
  71.    /* copy the message to eight positions in the workspace */
  72.  
  73.    fg_setcolor(12);
  74.    y = 80;
  75.    for (x = 0; x < 8; x++)
  76.    {
  77.       put_bstring(message,x,y);
  78.       y -= 10;
  79.    }
  80.  
  81.    /* scroll the message into the status area */
  82.  
  83.    delay = clockspeed / 6;
  84.  
  85.    newx = 288;
  86.    newy = 23;
  87.  
  88.    while (newx >= 24)
  89.    {
  90.       flushkey();
  91.       maxx = 295 - newx;
  92.       for (miny = 2; miny <= 72; miny+=10)
  93.       {
  94.          fg_transfer(0,maxx,miny,miny+8,newx,newy,HIDDEN,VISUAL);
  95.          fg_stall(delay);
  96.       }
  97.       newx -= 8;
  98.    }
  99.  
  100.    /* scroll the message out of the status area */
  101.  
  102.    minx = 8;
  103.    maxx = ((strlen(message)*6+7) & 0xFFF8) + 8;
  104.  
  105.    while (minx < maxx)
  106.    {
  107.       flushkey();
  108.       for (miny = 2; miny <= 72; miny+=10)
  109.       {
  110.          fg_transfer(minx,maxx,miny,miny+8,24,newy,HIDDEN,VISUAL);
  111.          fg_stall(delay);
  112.       }
  113.       minx += 8;
  114.    }
  115.    fg_setpage(VISUAL);
  116. }
  117.